Skip to content

Conversation

@abfeb8
Copy link

@abfeb8 abfeb8 commented Jul 27, 2025

Fixes #2835.

This PR adds a new feature to display JSON paths in HTML result generated by Spectral.
It introduces a new CLI option --html-include-json-path that, when enabled, shows the JSON path for each reported issue in the HTML output, making it easier to locate and fix issues in large documents.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Screenshots

  • HTML format result with --html-include-json-path true
image
  • HTML format result without flag
image

Changes

  • Added --html-include-json-path CLI option (default: false)
  • Created HtmlFormatterOptions type to support HTML-specific formatter options
  • Modified HTML formatter to include JSON paths when requested
  • Updated HTML templates to add a column for JSON path display

Additional context

This enhancement improves the HTML report's usefulness by providing clear location information for each validation error through JSON paths. When diagnosing issues in complex API definitions, knowing the exact JSON path makes troubleshooting significantly faster.

The implementation uses the existing printPath utility from @stoplight/spectral-runtime to format paths in dot notation style. The JSON path is only included when specifically requested via the CLI option, maintaining backward compatibility with existing usage.

@abfeb8 abfeb8 requested a review from a team as a code owner July 27, 2025 11:24
@abfeb8 abfeb8 changed the title Add JSON Path display option to HTML formatter feat(Format): Add JSON Path display option to HTML formatter Jul 27, 2025
@abfeb8 abfeb8 marked this pull request as draft July 27, 2025 11:48
@abfeb8 abfeb8 changed the title feat(Format): Add JSON Path display option to HTML formatter feat(cli): Add JSON Path display option to HTML formatter Jul 27, 2025
@abfeb8 abfeb8 changed the base branch from develop to fix/cli/deps July 27, 2025 13:28
@abfeb8 abfeb8 changed the base branch from fix/cli/deps to develop July 27, 2025 13:28
@abfeb8 abfeb8 marked this pull request as ready for review July 27, 2025 15:17
@abfeb8 abfeb8 changed the title feat(cli): Add JSON Path display option to HTML formatter feat(cli): add json path display option to html formatter Jul 29, 2025
@abfeb8
Copy link
Author

abfeb8 commented Jul 29, 2025

opend new PR with commint lint fix

@abfeb8 abfeb8 closed this Jul 29, 2025
@abfeb8 abfeb8 deleted the feature/json-path-in-html-format branch July 29, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Include JsonPath in HTML Format

2 participants